//----------获取元素-----------
var themeImg = $('#background-img');

//------------ready---------------
$(document).ready(function(){
	themeImg.setFullPage();
	theme();
/*	$('.add').on('change',function(){
		var url = $('#file').val();
		if(url){
			alert(url);
			console.log(url);
		}
	})*/
})

//-----------resize-------------
$(window).resize(function(){
	themeImg.setFullPage();
})

//-----------自定义插件------------------
$.fn.extend({ 
	setFullPage:function(){ 
		$(this).width(innerWidth);
		$(this).height(innerHeight);
	} 
}); 
function theme(){
	$('#setting').click(function(){
		$('#theme').css({
			bottom:		0,
			opacity:	1
		})
	})
	$('.closeSin').click(function(){
		$('#theme').css({
			bottom:		'-200px',
			opacity:	0
		})
	})
	$('.theme-img img').click(function(){
		$('#background-wrap').css({
			backgroundColor:		"rgba(0,0,0,.2)",
		});
		$('.checked').hide();
		$(this).next().show();
		$('#background-img').css({
			opacity:	.8,
			backgroundImage:	"url("+$(this).attr("src")+")",
		}).animate({
			opacity:	1,
		},500);
	});
	
	var flagl = false;
	var flagr = false;
	$('#theme .arrow-left').click(function(){
		if(flagl) return;
		flagl = true;
		if($('.theme-img ul').position().left<0){
			$('.theme-img ul').animate({
				left:	$('.theme-img ul').position().left+190+'px',
			},200,function(){
				flagl=false;
				flagr=false;
			})
			console.log(flagl);
			console.log(flagr);
		}	
	})
	$('#theme .arrow-right').click(function(){
		if(flagr) return;
		flagr = true;
		if($('.theme-img ul').position().left>-(1700-$('.theme-img').width())){
			$('.theme-img ul').animate({
				left:	$('.theme-img ul').position().left-190+'px',
			},200,function(){
				flagl=false;
				flagr=false;
			})
			console.log(flagl);
			console.log(flagr);
		}		
	})
	if(typeof FileReader==='undefined'){ 
	//	alert("抱歉，你的浏览器不支持 FileReader");
	    $('.add').setAttribute('disabled','disabled'); 
	}else{ 
		
	} 
}
//
//(function($){ 
//jQuery.fn.extend({ 
//uploadPreview: function(opts){ 
//opts = jQuery.extend({ 
//width: 0, 
//height: 0, 
//imgPreview: null, 
//imgType: ["gif", "jpeg", "jpg", "bmp", "png"], 
//callback: function(){ return false; } 
//}, opts || {}); 
//
//var _self = this; 
//var _this = $(this); 
//var imgPreview = $(opts.imgPreview); 
////设置样式 
//autoScaling = function(){ 
//imgPreview.css({"margin-left": 0,"margin-top": 0,"width":opts.width,"height":opts.height}); 
//imgPreview.show(); 
//} 
////file按钮出发事件 
//_this.change(function(){ 
//if (this.value) { 
//if (!RegExp("\.(" + opts.imgType.join("|") + ")$", "i").test(this.value.toLowerCase())) { 
//alert("图片类型必须是" + opts.imgType.join("，") + "中的一种"); 
//this.value = ""; 
//return false; 
//} 
//if ($.browser.msie) {//判断ie 
//var path = $(this).val(); 
//if (/"\w\W"/.test(path)) { 
//path = path.slice(1,-1); 
//} 
//imgPreview.attr("src",path); 
//imgPreview.css({"margin-left": 0,"margin-top": 0,"width":opts.width,"height":opts.height}); 
//setTimeout("autoScaling()", 100); 
//} 
//else { 
//if ($.browser.version < 7) { 
//imgPreview.attr('src', this.files.item(0).getAsDataURL()); 
//} 
//else { 
//oFReader = new FileReader(), rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i; 
//oFReader.onload = function(oFREvent){ 
//imgPreview.attr('src', oFREvent.target.result); 
//}; 
//var oFile = this.files[0]; 
//oFReader.readAsDataURL(oFile); 
//} 
//imgPreview.css({"margin-left": 0,"margin-top": 0,"width":opts.width,"height":opts.height}); 
//setTimeout("autoScaling()", 100); 
//} 
//} 
//opts.callback(); 
//}); 
//} 
//}); 
//})(jQuery); 
